package com.zhx.basis.设计模式.责任链.demo2;

public abstract class AbstractVerificationHandler implements IVerificationHandler {

    private IVerificationHandler handler;


    @Override
    public Response handleRequest(Request request) {
        Response response = doHandle(request);
        if (!response.getIsOk()) {
            return response;
        } else {
            if (null!=handler){
                return handler.handleRequest(request);
            }
        }
        return response;
    }


    /**
     * 处理该请求
     *
     * @param request
     * @return
     */
    protected abstract Response doHandle(Request request);

    @Override
    public void setSuccessor(IVerificationHandler verificationHandler) {
        handler = verificationHandler;
    }
}
